// ip
package main

import (
	"fmt"
	"net"
	"os"
	"strings"
)

func Ipv4ToHexstr(ipv4 string) string {
	ip := net.ParseIP(ipv4)
	if ip != nil {
		ip = ip.To4()
		return fmt.Sprintf("%08x", []byte(ip))
	}

	return ""
}
func main() {
	if len(os.Args) < 2 {
		fmt.Println("ip地址编码工具，用法：")
		fmt.Println("\t", os.Args[0], "ip地址 ip地址 ...")
		os.Exit(0)
	}
	for _, ip := range os.Args[1:] {
		c := Ipv4ToHexstr(ip)
		fmt.Printf("%15s %s %s\n", ip, c, strings.ToUpper(c))
	}
}
